<?php
$menu      = array();
$childMenu = array();

if (Users::checkAccess('index', Users::TYPE_ADMIN))
{
    $childMenu[] = array(
        'label'  => Yii::t('user', 'Administrator'),
        'url'    => url("admin/index"),
        'icon'   => 'icon-user-md',
        'active' => strtolower(Users::TYPE_ADMIN)
    );
}
if (Users::checkAccess('index', Users::TYPE_CUSTOMER))
{
    $childMenu[] = array(
        'label'  => Yii::t('user', 'Customer'),
        'url'    => url("customer/index"),
        'icon'   => 'icon-user-md',
        'active' => strtolower(Users::TYPE_CUSTOMER)
    );
}
if (!empty($childMenu))
{
    $menu[] = array(
        'label' => Yii::t('user', 'User Management'),
        'icon'  => 'icon-group',
        'items' => $childMenu
    );
};

// Menu cho Phân quyền
unset($childMenu);
$childMenu = array();
if (Users::checkAccess('index', 'auth'))
{
    $childMenu[] = array(
        'label'  => Yii::t('auth', 'Role'),
        'url'    => url('auth/index'),
        'icon'   => 'icon-list-ul',
        'active' => 'auth'
    );
}

if (Users::checkAccess('auto', 'auth'))
{
    $childMenu[] = array(
        'label'  => Yii::t('auth', 'Operation'),
        'url'    => url('auth/index', array('type' => AuthItem::TypeOperation)),
        'icon'   => 'icon-check',
        'active' => 'authOpera',
    );
}

if (!empty($childMenu))
{
    $menu[] = array(
        'label' => Yii::t('user', 'Authorization'),
        'icon'  => 'icon-group',
        'items' => $childMenu,
    );
}


    if (Users::checkAccess('index', 'order'))
    {
        $childMenu[] = array(
            'label'  => 'POS',
            'url'    => url('order/index'),
            'icon'   => 'icon-list-alt',
            'active' => 'order'
        );
    }
if (Users::checkAccess('sale', 'report'))
{
    $childMenu[] = array(
        'label'  => 'Report sale',
        'url'    => url('report/sale'),
        'icon'   => 'icon-list-alt',
        'active' => 'report'
    );
}
if (!empty($childMenu))
{
    $menu[] = array(
        'label' => 'Order',
        'icon'  => 'icon-book',
        'items' => $childMenu,
    );
}

unset($childMenu);
$childMenu = array();
if (Users::checkAccess('index', 'Option'))
{
    $childMenu[] = array(
        'label'  => 'Option List',
        'url'    => url('option/index'),
        'icon'   => 'icon-h-sign',
        'active' => 'option'
    );
}
if (Users::checkAccess('index', 'Header'))
{
    $childMenu[] = array(
        'label'  => 'Header',
        'url'    => url('header/index'),
        'icon'   => 'icon-h-sign',
        'active' => 'header'
    );
}

if (Users::checkAccess('index', 'Footer'))
{
    $childMenu[] = array(
        'label'  => 'Footer',
        'url'    => url('footer/index'),
        'icon'   => 'icon-info-sign',
        'active' => 'footer'
    );
}

if (Users::checkAccess('index', 'Page'))
{
    $childMenu[] = array(
        'label'  => 'Page',
        'url'    => url('page/index'),
        'icon'   => 'icon-file-alt',
        'active' => 'page'
    );
}

if (Users::checkAccess('index', 'Layout'))
{
    $childMenu[] = array(
        'label'  => 'Layout',
        'url'    => url('layout/index'),
        'icon'   => 'icon-columns',
        'active' => 'layout'
    );
}

if (Users::checkAccess('index', 'Widget'))
{
    $childMenu[] = array(
        'label'  => 'Widget',
        'url'    => url('widget/index'),
        'icon'   => 'icon-magnet',
        'active' => 'widget'
    );
}
if (Users::checkAccess('index', 'Slider'))
{
    $childMenu[] = array(
        'label'  => 'Slider Items',
        'url'    => url('slider/index'),
        'icon'   => 'icon-magnet',
        'active' => 'slider'
    );
}
if (Users::checkAccess('index', 'Area'))
{
    $childMenu[] = array(
        'label'  => 'Area',
        'url'    => url('area/index'),
        'icon'   => 'icon-home',
        'active' => 'area'
    );
}

if (Users::checkAccess('index', 'Contact'))
{
    $childMenu[] = array(
        'label'  => 'Contact Message',
        'url'    => url('contact/index'),
        'icon'   => 'icon-envelope',
        'active' => 'contact'
    );
}

if (Users::checkAccess('index', 'Subscribe'))
{
    $childMenu[] = array(
        'label'  => 'Subscription',
        'url'    => url('subscribe/index'),
        'icon'   => 'icon-star',
        'active' => 'subscribe'
    );
}

if (!empty($childMenu))
{
    $menu[] = array(
        'label' => 'CMS',
        'icon'  => 'icon-columns',
        'items' => $childMenu,
    );
}

// Menu cho Appointment
unset($childMenu);
$childMenu = array();



if (Users::checkAccess('notification', 'Setting'))
{
    $childMenu[] = array(
        'label'  => Yii::t('Setting', 'Notification'),
        'url'    => url('setting/notification'),
        'icon'   => 'icon-envelope',
        'active' => 'setting'
    );
}
if (Users::checkAccess('index', 'service'))
{
    $childMenu[] = array(
        'label'  => Yii::t('Service', 'Service'),
        'url'    => url('service/index'),
        'icon'   => 'icon-glass',
        'active' => 'service'
    );
}
if (Users::checkAccess('index', 'group'))
{
    $childMenu[] = array(
        'label'  => Yii::t('Group', 'Staff Labels'),
        'url'    => url('group/index'),
        'icon'   => 'icon-group',
        'active' => 'group'
    );
}
if (Users::checkAccess('index', 'category'))
{
    $childMenu[] = array(
        'label'  => 'Category',
        'url'    => url('category/index'),
        'icon'   => 'icon-list',
        'active' => 'category'
    );
}
if (!empty($childMenu))
{
    $menu[] = array(
        'label' => Yii::t('Setting', 'Setting'),
        'icon'  => 'icon-cog',
        'items' => $childMenu
    );
}

/*
 * Menu for Report
 */
unset($childMenu);
$childMenu = array();

if (Users::checkAccess('index', 'accessLog'))
{
    $childMenu[] = array(
        'label'  => 'Access Log',
        'url'    => url('accessLog/index'),
        'icon'   => 'icon-reorder',
        'active' => 'accessLog',
    );
}

if (!empty($childMenu))
{
    $menu[] = array(
        'label' => 'Report',
        'icon'  => 'icon-briefcase',
        'items' => $childMenu
    );
}
return $menu;
/**
 * End of MainMenu
 */
